from flask import g, render_template, current_app
from flask.views import MethodView


class Dashboard(object):
    dispaly_name = None
    prifex = None
    panels = []

    def __init__(self, app):
        self.app = app
        if not hasattr(app, "dashboards"):
            setattr(app, "dashboards", [])
        app.dashboards.append(self)
        self.register_panels()

    def get_display_name(self):
        if None == self.dispaly_name:
            raise NotImplementedError()
        return self.dispaly_name

    def get_prifex(self):
        if None == self.prifex:
            raise NotImplementedError()
        return self.prifex
    
    def register_panels(self):
        for panel in self.panels:
            panel().register(self.get_prifex(), self.app)